<html>
<style type="text/css">
body {
	font-family:verdana,arial,sans-serif;
	font-size:10pt;
	margin:30px;
	background-color:#ffcc00;
	}
</style>


<a href ="editemployee.php" target = "_top">Edit another employee</a><br />

</html>

<?php

if(isset($_POST['origID']))
{
    $username="bsc353_4";
    $password="sonbeans";
    $database="bsc353_4";
    mysql_connect("clipper.encs.concordia.ca",$username,$password);

    @mysql_select_db($database) or die ("Unable to select database");


    $originalID = $_POST['origID'];
    

    if (isset($_POST['delete'])) //if user chose to delete
    {
        $query = "DELETE FROM Employee WHERE EmployeeID = '$originalID'";
    }
    else //user chose to edit one or more of the employee's fields
    {
        $employeeID=$_POST['employeeID'];
        $storeBranchID=$_POST['storeBranchID'];
        $name=$_POST['name'];

        $query="UPDATE Employee SET employeeID=$employeeID, storeBranchID= '$storeBranchID', name = '$name' 
        WHERE employeeID = '$originalID';";
 
    }
    
    //echo $query;
    mysql_query($query) or die ("failed to add record");

    if(isset($_POST['save']))
        echo "Record successfully edited";
    else if(isset($_POST['delete']))
        echo "Record successfully deleted";
	
    mysql_close();
}
else
{
    echo "need to choose an employee first";
}



?> 

